package com.lhn;

import com.lhn.dao.UserDao;
import com.lhn.factory.UserDaoFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author lhn
 * @date 2024-08-16 15:38
 */

public class AppForInstanceUser {
    public static void main(String[] args) {
        //通过工厂方法创建对象
        UserDao userDao = new UserDaoFactory().getUserDao();
        System.out.println(userDao);
        userDao.save();

        System.out.println("============================");

        ApplicationContext ctx = new ClassPathXmlApplicationContext("application.xml");
        UserDao userDao1 = (UserDao) ctx.getBean("userDao");
        UserDao userDao2 = (UserDao) ctx.getBean("userDao");
        System.out.println("userDao1 is " + userDao1);
        System.out.println("userDao2 is " + userDao2);
        userDao1.save();
    }
}
